package com.jeesite.modules.exam.score.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jeesite.modules.exam.notice.entity.DcSupExamNotice;
import com.jeesite.modules.exam.notice.service.DcSupExamNoticeService;
import com.jeesite.modules.exam.quota.service.DcSupExamQuotaOrgService;
import com.jeesite.modules.exam.score.entity.DcSupExamScoreInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.exam.score.service.DcSupExamScoreService;

/**
 * 考核任务指标评分表Controller
 * @author xhc
 * @version 2022-06-01
 */
@Controller
@RequestMapping(value = "${adminPath}/score/dcSupExamScore")
public class DcSupExamScoreController extends BaseController {

	@Autowired
	private DcSupExamScoreService dcSupExamScoreService;

	@Autowired
	private DcSupExamNoticeService dcSupExamNoticeService;

	@Autowired
	private DcSupExamQuotaOrgService dcSupExamQuotaOrgService;

	/**
	 * 获取数据
	 */
	@ModelAttribute
	public DcSupExamScoreInfo get(String id, boolean isNewRecord) {
		return dcSupExamScoreService.get(id, isNewRecord);
	}



	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("score:dcSupExamScore:view")
	@RequestMapping(value = {"list", ""})
	public String list(DcSupExamScoreInfo dcSupExamScoreInfo, Model model) {
		model.addAttribute("dcSupExamScore", dcSupExamScoreInfo);
		return "modules/score/dcSupExamScoreList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("score:dcSupExamScore:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<DcSupExamScoreInfo> listData(DcSupExamScoreInfo dcSupExamScoreInfo, HttpServletRequest request, HttpServletResponse response) {
		dcSupExamScoreInfo.setPage(new Page<>(request, response));
		Page<DcSupExamScoreInfo> page = dcSupExamScoreService.findPage(dcSupExamScoreInfo);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("score:dcSupExamScore:view")
	@RequestMapping(value = "form")
	public String form(DcSupExamScoreInfo dcSupExamScoreInfo, Model model) {
		model.addAttribute("dcSupExamScore", dcSupExamScoreInfo);
		return "modules/score/dcSupExamScoreForm";
	}

	/**
	 * 保存数据
	 */
	@RequiresPermissions("score:dcSupExamScore:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated DcSupExamScoreInfo dcSupExamScoreInfo) {
		dcSupExamScoreService.save(dcSupExamScoreInfo);
		return renderResult(Global.TRUE, text("保存考核任务指标评分表成功！"));
	}
	
	/**
	 * 删除数据
	 */
	@RequiresPermissions("score:dcSupExamScore:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(DcSupExamScoreInfo dcSupExamScoreInfo) {
		dcSupExamScoreService.delete(dcSupExamScoreInfo);
		return renderResult(Global.TRUE, text("删除考核任务指标评分表成功！"));
	}
	
}